/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Raytracing.BRDF;

import Raytracing.Fresnel;
import Raytracing.Ray;
import processing.core.PVector;

/**
 *
 * @author Matt
 */
public class SpecularReflectionBRDF implements BRDF {

    PVector R;
    Fresnel fresnel;

    public SpecularReflectionBRDF(Fresnel fresnel, PVector R) {
        this.fresnel = fresnel;
        this.R = R;
    }

    public PVector getReflectance(PVector incoming, PVector outgoing, PVector normal, float tu, float tv, PVector u, PVector v) {

        return new PVector(0, 0, 0);

    }

    public float sampleReflectance(PVector outgoing, Ray sample,
            PVector normal, PVector BRDF,
            float tu, float tv, PVector u, PVector v,
            float u1, float u2) {


        sample.direction.x = -outgoing.x;
        sample.direction.y = -outgoing.y;
        sample.direction.z = outgoing.z;

        BRDF.set(fresnel.getFresnel(cosTheta(outgoing)));

        BRDF.mult(R);
        sample.bounceType = Ray.SPECULAR;
        return 1f;
    }

    public float cosTheta(PVector vec) {
        return vec.z;
    }
}
